<?php

namespace app\model;

use think\Model;

class Sysconfig extends Model
{


    protected $connection = 'mysql';

    protected $pk = 'id';

    protected $name = 'sys_config';


    public static function getconfig($module = '')
    {

        if (empty($module)) {
            $module = 'common';
        }
        $config = self::where(['weid' => weid(), 'module' => $module])
            ->find();

        if (!empty($config)) {
            $config = $config->toArray();
            if (!empty($config['settings'])) {
                $r = iunserializer($config['settings']);

                if (empty($r['filesize'])) {
                    $r['filesize'] = 10;
                }

                if (empty($r['filesize'])) {
                    $r['filesize'] = 10;
                }

                if (empty($r['filetype'])) {
                    $r['filetype'] = 'jpg,jpeg,png,gif';
                }
            }
            $r['id'] = $config['id'];

            if(empty($r['domain'])){
                $r['domain'] = gethost();
            }
        }

        return $r;
    }
}
